package com.top.mall.main.mine

import android.app.Activity
import android.content.Intent
import android.graphics.Color
import com.blankj.utilcode.util.BarUtils
import com.blankj.utilcode.util.ConvertUtils
import com.module.lemlin.owner.OwnerViewModeActivity
import com.top.mall.R
import com.top.mall.custom.SpacingItemDecoration
import com.top.mall.jetpack.vm.CouponViewModel
import com.top.mall.main.mine.adapter.MineInvoiceAdapter
import kotlinx.android.synthetic.main.activity_mine_invoice.*
import kotlinx.android.synthetic.main.activity_mine_invoice.imageViewBack

class MineInvoiceActivity : OwnerViewModeActivity<CouponViewModel>() {

    companion object {
        fun open(activity: Activity) {
            val intent = Intent(activity, MineInvoiceActivity::class.java)
            activity.startActivity(intent)
        }
    }

    private val mineInvoiceAdapter: MineInvoiceAdapter = MineInvoiceAdapter()

    override fun viewModel(): CouponViewModel {
        return createViewModel()
    }

    override val layoutResId: Int
        get() = R.layout.activity_mine_invoice

    override fun stateBar(): StatusBar {
        return StatusBar(view = flMineInvoiceBar)
    }

    override fun initView() {

        imageViewBack.setOnClickListener { finish() }
        BarUtils.setStatusBarColor(this, Color.WHITE)

        rvMineInvoiceBody.apply {
            val decoration = SpacingItemDecoration(
                vGap = ConvertUtils.dp2px(12f),
                hGap = ConvertUtils.dp2px(20f)
            )
            addItemDecoration(decoration)
        }.adapter = mineInvoiceAdapter
    }

    override fun initData() {
        val address: MutableList<String> = mutableListOf()
        for (index: Int in 0..2) {
            address.add(index.toString())
        }
        mineInvoiceAdapter.setNewInstance(address)
    }

}